const state = {
  hasLogin: false,
  friends: [] // 上线好友数据
}

const mutations = {
  SET_HAS_LOGIN(state, data) {
    state.hasLogin = data
  },
  SET_FRIENDS(state, data) {
    state.friends.push(data)
  },
  REMOVE_FRIENDS(state, data) {
    state.friends.map((item, index) => {
      if (item.id === data) {
        state.friends.splice(index, 1)
      }
    })
  }
}

const actions = {
  setHasLogin({ commit }, data) {
    commit('SET_HAS_LOGIN', data)
  },
  setFriends({ commit }, data) {
    commit('SET_FRIENDS', data)
  },
  removeFriends({ commit }, data) {
    commit('REMOVE_FRIENDS', data)
  }
}
export default {
  state,
  mutations,
  actions
}
